<?php

Yii::import('zii.widgets.CPortlet');

class SideBar extends CPortlet
{
	public $title='Aktuelles:';
	public $infoTitle='Infos:';
	public $hasNews=true;
	public $hasInfoOnly=false;
	public $hasInfo=false;	
	public $tagCloudExcludes;
	public $infoText='?';
	
	
	private function getLastNews()
	{
		return News::model()->getLastNews(Yii::app()->params['siteId'],Yii::app()->params['newsPerPage']);
	}
	
	protected function renderContent()
	{
		if($this->hasInfoOnly){
			echo $this->infoText;
		}
		else{
			if($this->hasInfo){
				echo $this->infoText;
			}
		foreach($this->getLastNews() as $news): ?>
			<p><?php echo $news->startdate.' <b>'.$news->shorttext; ?> </b><br />
			<?php echo $news->longtext; ?> </p>
			<?php endforeach; 
		}
	}
}